package com.yxj_01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

class Student {
    String name;
    int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
public class TestStu {

    public static void main(String[] args) {
        Collection<Student> c = new ArrayList<Student>();

        //创建学生对象
        Student s1 = new Student("yxj",12);
        Student s2 = new Student("yxx",34);
        Student s3 = new Student("xxx",33);

        //吧学生添加到集合
        c.add(s1);
        c.add(s2);
        c.add(s3);

        Iterator<Student> it = c.iterator();
        while(it.hasNext()) {
            Student s = it.next();
            System.out.println(s.getName() + "," + s.getAge());
        }
    }
}
